﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Com.CMS263.PO;
using Com.CMS263.DAO;
using Com.CMS263.Util;

namespace Com.CMS263.BLL
{
    public class CustomerListBLL : BaseBLL<CustomerList>
    {
        public CustomerList cus = new CustomerList();
        CustomerListDAO dao = new CustomerListDAO();
        /// <summary>
        /// 根据email查询实体
        /// </summary>
        /// <param name="UEmail"></param>
        /// <returns></returns>
        public int UserEmailIteration(string UEmail)
        {
            return dao.UserEmailIteration(UEmail);
        }


        public override CustomerList GetModel()
        {
            return cus;
        }

        public int UseruserNameIteration(string userName)
        {
            return dao.UseruserNameIteration(userName);
        }
        /// <summary>
        /// 根据用户名和密码查询
        /// </summary>
        /// <param name="mobile"></param>
        /// <param name="pass"></param>
        /// <returns></returns>
        public bool FindModelByuserNameAndPass(string userName, string pass)
        {
            CustomerList cl = dao.FindModelByuserNameAndPass(userName, pass);
            if (cl != null)
            {
                LoginInfo li = new LoginInfo(cl.UserName, cl.Id);
                LoginCookie.SaveLoginInfo(li);
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 根据用户名和邮箱查询
        /// </summary>
        /// <param name="mobile"></param>
        /// <param name="email"></param>
        /// <returns></returns>
        public CustomerList FindModelByuserNameAndEmail(string userName, string email)
        {
            return dao.FindModelByuserNameAndEmail(userName, email);
        }

        public IList<CustomerList> FindList(string username, int page, int pageSize)
        {
            return dao.FindList(username, page, pageSize);
        }
        /// <summary>
        /// 根据用户名查询
        /// </summary>
        /// <param name="mobile"></param>
        /// <param name="pass"></param>
        /// <returns></returns>
        public CustomerList FindModelByuserName(string userName)
        {
            return dao.FindModelByuserName(userName);
        }
        public int GetCount(string username)
        {
            return dao.GetCount(username);
        }
    }
}
